package com.itheima;

import com.itheima.pojo.User;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2020-08-06 09:20
 * @description
 */
public class Test01 {
    public static void main(String[] args) {
        //创建一个spring的容器对象

        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        //根据id 获取
        User user01 = (User) context.getBean("user01");

        //也可以直接根据类型获取 注意一下 根据类型获取的时候 只能有一个 不然就报错了

        User user02 = context.getBean(User.class);

        //根据类型和名字获取 省去了 你强转的过程

        User user03 = context.getBean("user01", User.class);



    }
}
